﻿using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NTmdb.TestProject
{
    /// <summary>
    ///     This is a test class for TmdbMovieListPreviewTest and is intended
    ///     to contain all TmdbMovieListPreviewTest Unit Tests
    /// </summary>
    [TestClass]
    public class TmdbMovieListPreviewTest
    {
        /// <summary>
        ///     A test for TmdbMovieListPreview Constructor
        /// </summary>
        [TestMethod]
        public void TmdbMovieListPreviewConstructorTest()
        {
            var target = new TmdbMovieListPreview();
            Assert.IsNotNull( target );
        }

        /// <summary>
        ///     A test for Description
        /// </summary>
        [TestMethod]
        public void DescriptionTest()
        {
            var target = new TmdbMovieListPreview();
            string expected = Guid.NewGuid().ToString();
            target.Description = expected;
            string actual = target.Description;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for FavoriteCount
        /// </summary>
        [TestMethod]
        public void FavoriteCountTest()
        {
            var target = new TmdbMovieListPreview();
            int expected = new Random().Next( 0, Int32.MaxValue );
            target.FavoriteCount = expected;
            int actual = target.FavoriteCount;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for Id
        /// </summary>
        [TestMethod]
        public void IdTest()
        {
            var target = new TmdbMovieListPreview();
            string expected = Guid.NewGuid().ToString();
            target.Id = expected;
            string actual = target.Id;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for Iso639_1
        /// </summary>
        [TestMethod]
        public void Iso639_1Test()
        {
            var target = new TmdbMovieListPreview();
            string expected = Guid.NewGuid().ToString();
            target.Iso639_1 = expected;
            string actual = target.Iso639_1;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for ItemCount
        /// </summary>
        [TestMethod]
        public void ItemCountTest()
        {
            var target = new TmdbMovieListPreview();
            int expected = new Random().Next( 0, Int32.MaxValue );
            target.ItemCount = expected;
            int actual = target.ItemCount;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for ListType
        /// </summary>
        [TestMethod]
        public void ListTypeTest()
        {
            var target = new TmdbMovieListPreview();
            string expected = Guid.NewGuid().ToString();
            target.ListType = expected;
            string actual = target.ListType;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for Name
        /// </summary>
        [TestMethod]
        public void NameTest()
        {
            var target = new TmdbMovieListPreview();
            string expected = Guid.NewGuid().ToString();
            target.Name = expected;
            string actual = target.Name;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for PosterPath
        /// </summary>
        [TestMethod]
        public void PosterPathTest()
        {
            var target = new TmdbMovieListPreview();
            string expected = Guid.NewGuid().ToString();
            target.PosterPath = expected;
            string actual = target.PosterPath;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for Serialize & Deserialize
        /// </summary>
        [TestMethod]
        [DeploymentItem( @"..\..\TestData\movieListPreview.json.txt" )]
        public async Task SerializeDeserializeTest()
        {
            var target = new TmdbMovieListPreview();
            var jsonContent = File.ReadAllText( "movieListPreview.json.txt" );
            var actual = await target.DeserializeJson<TmdbMovieListPreview>( jsonContent );
            
            Assert.IsTrue( false, "is list type needed?" );
            Assert.AreEqual( "Must watch Sci-Fi films for 2013, in no particular order.", actual.Description );
            Assert.AreEqual( 20, actual.FavoriteCount );
            Assert.AreEqual( "50cbe90b19c2956de8047b4f", actual.Id );
            Assert.AreEqual( 10, actual.ItemCount );
            Assert.AreEqual( "en", actual.Iso639_1 );
            Assert.AreEqual( "Sci-Fi films to see in 2013", actual.Name );
            Assert.AreEqual( "/pmyZRPocfjmXaGBddtz8EmlfrRX.jpg", actual.PosterPath );
        }
    }
}